// index.js
const { websites } = require("./config");
const { checkWebsite, sendWechatNotification } = require("./utils");

// 定义检查的间隔时间（以毫秒为单位），例如5分钟
const CHECK_INTERVAL = 1 * 60 * 1000;

async function checkWebsites() {
  for (const website of websites) {
    const isAccessible = await checkWebsite(website);
    if (!isAccessible) {
      const message = `访问 ${website} 失败，请 <@hejing> 注意`;
      await sendWechatNotification(message);
    }
  }
}

function startChecking() {
  checkWebsites();
  setInterval(checkWebsites, CHECK_INTERVAL);
}

startChecking();
